﻿namespace LearnDSSortings;

public class SelectionSort
{
    public void Search(int[] arr)
    {
        int n = arr.Length;
        for (int i = 0; i < n - 1; i++)
        {
            int position = i;
            for (int j = i + 1; j < n; j++)
            {
                if (arr[j] < arr[position])
                    position = j;
            }

            Swap(arr, i, position);
        }
    }

    private void Swap(int[] arr, int i, int j)
    {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}